package chapter07_object;

import java.util.Objects;

/**
 * ClassName: UserTest1
 * Package: chapter07_object
 * Description:
 *
 *Object类中的equals()方法。
 *
 * @Author SherryAn
 * @Create 2025/7/19 17:10
 */
public class UserTest1 {
    public static void main(String[] args) {

        User1 u1=new User1("Tom",12);
        User1 u2=new User1("Amy",13);

        System.out.println(u1.equals(u2));

        String s1=new String("Hello");
        String s2=new String("Hello");
        System.out.println(s1==s2);
        System.out.println(s1.equals(s2));


    }
}

class User1{
    String name;
    int age;

    public User1(){

    }

    public User1(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }
}
